// 1.导入相关插件
import Vue from 'vue'
import Vuex from 'vuex'

import mutations from './mutations'
import actions from './actions'
import getters from './getters'
import moduleOne from './modules/moduleOne'
import moduleTwo from './modules/moduleTwo'

// 2.安装插件
Vue.use(Vuex)

// 3.导出实例化对象
export default new Vuex.Store({
  // 状态：相当于data,用于存放需要共同管理的数据
  state: {
    count:10,
    students:[
      {name:"qwe",age:18},
      {name:"xyz",age:28},
      {name:"asd",age:21},
      {name:"zxc",age:25},
    ],
    person:{
      name:"小米",
      age:18,
      height:190
    }
  },
  // getters类似于Vue组件中的computed计算属性，计算一些需要二次改造的数据
  getters,
  mutations,
  actions,
  modules: {
    one:moduleOne,
    two:moduleTwo
  }
})


// 4.在入口文件中导入实例化对象